﻿namespace Insight
{
    using System.Windows.Controls;
    using System.Windows.Navigation;
    using System.Windows;
    using Insight.Web.Services;
    using Insight.LoginUI;
    using System.ServiceModel.DomainServices.Client.ApplicationServices;
    using Insight.Library.Navigation;
    /// <summary>
    /// Home page for the application.
    /// </summary>
    [RequiresAuthentication]
    public partial class Home : Page
    {
        private readonly AuthenticationService authService = WebContext.Current.Authentication;

        /// <summary>
        /// Creates a new <see cref="Home"/> instance.
        /// </summary>
        public Home()
        {
            InitializeComponent();
            this.Title = ApplicationStrings.HomePageTitle;
            // Loaded += new RoutedEventHandler(Home_Loaded); 
        }

        

        //private void Home_Loaded(object sender, RoutedEventArgs e)
        //{
        //    //if (!WebContext.Current.User.IsAuthenticated)
        //    //{
        //    //    LoginRegistrationWindow loginWindow = new LoginRegistrationWindow();
        //    //    loginWindow.Show();
        //    //}

        //    EntityModelDomainContext ctx = new EntityModelDomainContext();
        //    UsersGrid.ItemsSource = ctx.WorkItems;
        //    ctx.Load(ctx.GetWorkitemsQuery());
        //}

        /// <summary>
        /// Executes when the user navigates to this page.
        /// </summary>
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
        }

        private void SubmitButton_Click(object sender, RoutedEventArgs e)
        {
            UsersSource.SubmitChanges();
        }
    }
}